package com.tenglong.teacher.ui.adapter.viewholder;

import android.view.View;
import android.widget.TextView;

import com.tenglong.teacher.R;
import com.tenglong.teacher.data.requestInfo.WorkPaperMistakesInfo;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;

/**
 * @author hdx on 2019/3/25.
 */
public class WorkPaperViewHolder extends BaseViewHolder<WorkPaperMistakesInfo> {
    private TextView circleText,cause;

    public WorkPaperViewHolder(View itemView) {
        super(itemView);
        initView();
    }

    private void initView() {
        circleText = itemView.findViewById(R.id.circleText);
        cause = itemView.findViewById(R.id.cause);
    }

    @Override
    public void setLayoutInfo(WorkPaperMistakesInfo info) {
        circleText.setText(info.index+"");
        if (info.errorCause!=null&&info.errorCause.size()>0){
            StringBuilder builder = new StringBuilder();
            builder.append("第");
            builder.append(info.index);
            builder.append("题：（");
            for (int i = 0 ; i < info.errorCause.size() ; i ++){
                String text = info.errorCause.get(i);
                if (i != 0){
                    builder.append("、");
                }
                builder.append(text);
            }
            builder.append("）");
            cause.setText(builder.toString());
        } else {
            cause.setText("未注释原因!");
        }
    }
}
